package com.timeDeal.servlet;










import com.timeDeal.bean.JubaoBean;
import com.timeDeal.service.JubaoService;
import com.timeDeal.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


/**
 * Created by Administrator on 2016/7/24.
 */

public class  JubaoChuliServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String  currentpage = request.getParameter("currentpage") ;

        System.out.println(currentpage);
        JubaoService jubaoService =new  JubaoService();
        List<JubaoBean>  result= new ArrayList<>() ;
        UserService us = new UserService() ;
        result = jubaoService.getAllJubao(Integer.valueOf(currentpage));
        String   max = jubaoService.getCount() ;
        List<String>  jubaorenname = new ArrayList<>() ;
        List<String>  jubaoreduixiangnname = new ArrayList<>() ;
        for (int i = 0; i <result.size() ; i++) {
            jubaorenname.add(us.getDetailById(result.get(i).getJubaorenid()));
            jubaoreduixiangnname.add(us.getDetailById(result.get(i).getJubaoduixiangid()));
        }
        request.setAttribute("jubaorenname", jubaorenname);
        request.setAttribute("jubaoduixiangname", jubaoreduixiangnname);
        request.setAttribute("result", result);
        request.setAttribute("max", max);
        request.setAttribute("currentpage",currentpage);
        request.getRequestDispatcher("/admin/jubaochuli.jsp").forward(request,response);





    }
}
